#include <stdint.h>
#include <stdbool.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/sysctl.h"
#include "driverlib/gpio.h"

//uint8_t ui8PinData=2; /// Keeps one LED on.
 uint8_t ui8PinData=6; /// Keeps two LEDs on. #Task3B

int main(void)
{

	SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);
	/// SysCtlClockSet(SYSCTL_SYSDIV_10|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN);/// #Task2B: Makes the clock twice as slow
	/// SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_OSC|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); /// #Task2C: Uses the external oscillator (16MHz clock)
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); //// Enable portF
	GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3); /// ENable pin 1,2,3 of port f

	while(1)
	{
		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, ui8PinData); // Write to pin 1,2,3 of ui8PinData
		SysCtlDelay(5000000); /// #Task2A Increased delay
		//SysCtlDelay(20000000); ///  second delay
		GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, 0x00); // Write to pin 1,2,3 of ui8PinData
		SysCtlDelay(5000000); /// #Task2A Increased delay
		SysCtlDelay(20000000); ///// 2 second delay
		if(ui8PinData==8) {ui8PinData=2;} else {ui8PinData=ui8PinData*2;} ///  Goes from R to B to G.
		if(ui8PinData==2) {ui8PinData=8;} else {ui8PinData=ui8PinData/2;} ///#Task3A  Goes from R to G to B
		ui8PinData<<=1; if(ui8PinData&16) ui8PinData = ((ui8PinData&15)|2); // #Task3B  Rotates through single colors and double colors

	}

}
